import { request } from '@/service/request';

/** 获取产品列表 */
export function fetchGetProductsList(PageRequest?: Api.Business.ProductsSearchParams) {
  return request<Api.Business.ProductsList>({
    url: '/products/getAll',
    method: 'post',
    data: PageRequest
  });
}

/** 新增产品 */
export function fetchCreateProducts(data: Api.Business.ProductsOperateParams) {
  return request<boolean>({
    url: '/products/add',
    method: 'post',
    headers: {
      isEncrypt: true,
      repeatSubmit: false
    },
    data
  });
}

/** 修改产品 */
export function fetchUpdateProducts(data: Api.Business.ProductsOperateParams) {
  return request<boolean>({
    url: '/products/update',
    method: 'post',
    data
  });
}

/** 批量删除产品 */
export function fetchBatchDeleteProducts(ids: CommonType.IdType[]) {
  return request<boolean>({
    url: `/products/delete`,
    method: 'delete',
    data: ids
  });
}

export function fetchDashboardsCard() {
  return request<Api.Business.DashboardCard>({
    url: '/dashboard/admin/card',
    method: 'get'
  });
}

export function fetchDashboardsLineChart() {
  return request<Api.Business.DashboardLineChart>({
    url: '/dashboard/admin/lineChart',
    method: 'get'
  });
}

